import AnnexUploadField from "components/AnnexUploadField";

import { connect, mapStyledProps } from '@formily/antd';

/**
 * 可配置x-component-props: {
 *  itemProps: {
 *    disabled: boolean,
 *    placeholder: string,
 *    contentpart: boolean, // 只显示内容，不显示模板
 *  },
 *  params: {
 *    params: {
 *      template: [{ fileName, url}],
 *      multiple: boolean,
 *    },
 *  }, 
 *  uploadProps: Props of antd Upload
 * }
 */
const CustomAnnexUploadFieldFormily = connect({
  getProps: (componentsProps, fieldProps) => {
    mapStyledProps(componentsProps, fieldProps);
    const { editable } = fieldProps;
    if (!componentsProps.itemProps){ // x-components-props中未设置itemProps
      componentsProps.itemProps = {};
    }
    if (componentsProps.itemProps.disabled === undefined) {
      componentsProps.itemProps.disabled = !editable;
    }
  },
})(AnnexUploadField);

export default CustomAnnexUploadFieldFormily;